catalan :: Int -> Int
catalan n = head (catalanList n)

catalanList :: Int -> [Int]
catalanList 0 = [1]
catalanList 1 = [1,1]
catalanList (n+2) = (sumatoria ls):ls
	where ls = catalanList (n+1)

sumatoria :: [Int] -> Int
sumatoria [] = 0
sumatoria [x] = x*x 
sumatoria (x:y:ys) = (2*x*lst) + sumatoria zs
	where 
		  lst = last (x:y:ys)
		  zs = init (y:ys)
